# cython: language_level=3
# -*- coding: utf-8 -*-
import utils
import time


def time_log(func):
    """
    时间打印装饰器（用于打印所用的时间
    :param func:
    :return:
    """
    def wrap(*arg, **kwargs):
        s = time.time()*1000
        utils.get_logger().info(s)
        result = func(*arg, **kwargs)
        e = time.time()*1000
        if utils.get_config().get('default','show_time_log') == 'true':
            utils.get_logger().info("time_log:%s|%s" % (func.__name__, int(e - s)))
        return result
    return wrap


@time_log
def print_log_test(i):
    sum = 1
    for index in range(i):
        sum += index
    utils.get_logger().info("result is : %s" % sum)
    return sum


if __name__ == '__main__':
    utils.get_logger().info("start")
    print_log_test(1000)
